package com.tw.utils;

import nl.bitwalker.useragentutils.Browser;
import nl.bitwalker.useragentutils.OperatingSystem;
import nl.bitwalker.useragentutils.UserAgent;


public class UserAgentUtil {

	/**
	 * 获取USERAGENT信息
	 * @param str 输入:useragent
	 * @return userAgent.getBrowser()+"\t" + browser.getBrowserType() +"\t" +userAgent.getOperatingSystem()
	 */
	public static String getUserAgentBrowser(String useragent){
		UserAgent userAgent = UserAgent.parseUserAgentString(useragent);
		Browser browser = userAgent.getBrowser();
		return browser.toString() ;
	}
	/**
	 * 获取移动设备信息
	 * @param useragent
	 * @return
	 */
	public static String getOperatingSystem(String useragent){
		UserAgent userAgent = UserAgent.parseUserAgentString(useragent);
		OperatingSystem os = userAgent.getOperatingSystem();
		return os.toString();
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String useragent = "Mozilla/5.0 (Linux; U; Android 2.3.6; zh-tw; E620 Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
		System.out.println(getUserAgentBrowser(useragent));
		System.out.println(getOperatingSystem(useragent));
	}

}
